#路由注册 - backend/main.py
#在主应用文件中，路由被注册到 FastAPI 应用：


from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from backend.routes import emails, system
import uvicorn

app = FastAPI(title="Auto Email Service", description="自动处理授权邮件服务")

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 包含路由
app.include_router(emails.router, prefix="/api/v1", tags=["邮件处理"])
app.include_router(system.router, prefix="/api/v1", tags=["系统管理"])

@app.get("/")
async def root():
    return {"message": "Auto Email Service is running"}

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)